package cn.hdmis.action;

import cn.hdmis.security.entity.User;
import cn.hdmis.util.AccountManager;
import cn.hdmis.util.SysMessageBean;

public class LoginAction extends BaseAction{
	private static final long serialVersionUID = 5418226752990425410L;
	private User user;
	private SysMessageBean msg;

	public void setUser(User user) {
		this.user = user;
	}

	public User getUser() {
		return user;
	}
	
	public String login(){
		try {
			msg = AccountManager.getInstance().login(user);
			if("error".equals(msg.getType())){
				responseJson(msg.toJson());
				return "faileUrl";
			}
		}catch (Exception e) {
			logger.error("登录验证未通过!", e.getMessage());
			return "faileUrl";
		}
		responseJson(msg.toJson());
		return "successUrl";
	}

	public void setMsg(SysMessageBean msg) {
		this.msg = msg;
	}

	public SysMessageBean getMsg() {
		return msg;
	}
}
